package org.kabeja.dxf.helpers;

import org.kabeja.dxf.entity.Bounds;
import org.kabeja.dxf.entity.DXFEntity;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @author shutao
 * @since 2022/4/24 17:44
 */
public class HatchBoundaryLoop {
    private List<DXFEntity> edges = new ArrayList<>();
    private boolean outermost = true;

    public HatchBoundaryLoop() {
    }

    public boolean isOutermost() {
        return this.outermost;
    }

    public void setOutermost(boolean var1) {
        this.outermost = var1;
    }

    public Iterator<DXFEntity> getBoundaryEdgesIterator() {
        return this.edges.iterator();
    }

    public void addBoundaryEdge(DXFEntity var1) {
        this.edges.add(var1);
    }

    public Bounds getBounds() {
        Bounds var1 = new Bounds();
        if (this.edges.size() > 0) {
            for (DXFEntity edge : this.edges) {
                Bounds var4 = edge.getBounds();
                if (var4.isValid()) {
                    var1.addToBounds(var4);
                }
            }
        } else {
            var1.setValid(false);
        }
        return var1;
    }

    public int getEdgeCount() {
        return this.edges.size();
    }
}
